@charset "utf-8";

@import '../../theme.scss';

.x-switch {
  display: inline-flex;
  width: px(100);
  height: px(54);
  background-color: var(--x-switch-bg-color);
  border-radius: px(27);
  transition: all 0.3s ease-out;
  position: relative;

  > em {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: px(46);
    height: px(46);
    position: absolute;
    left: px(4);
    top: px(4);
    background-color: #fff;
    transition: all 0.3s ease-out;

    svg {
      width: px(22);
      height: px(22);
    }

    path {
      fill: #ddd;
    }
  }

  &.x-switch--active {
    path {
      fill: var(--x-primary-color);
    }
  }

  &--active {
    background-color: var(--x-primary-color);

    em {
      transform: translate(px(46), 0);
    }
  }

  &--disabled {
    opacity: 0.5;

    &:active {
      opacity: 0.5 !important;
    }
  }

  &--io {
    width: px(120);

    sub,
    sup {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      font-style: normal;
      color: #fff;
      padding: 0 px(20);
      font-size: px(24);
      transition: opacity 0.2s ease-out;
      opacity: 0;
    }

    sub {
      justify-content: flex-end;
      opacity: 1;
    }

    &.x-switch--active {
      sub {
        opacity: 0;
      }

      sup {
        opacity: 1;
      }

      em {
        transform: translate(px(66), 0);
      }
    }
  }

  &--mini {
    width: px(78);
    height: px(44);

    > em {
      width: px(36);
      height: px(36);
    }

    &.x-switch--active {
      em {
        transform: translate(px(34), 0);
      }
    }
  }
}
